<template>
  <div>
    <div id="main"></div>
  </div>
</template>

<script>
import { defineComponent, onMounted } from "@vue/runtime-core";
import * as echarts from "echarts";
export default defineComponent({
  props: {
    typeArr: {
      type: Array,
    },
    echartData: {
      type: Array,
    },
  },
  setup(props, context) {
    const init = () => {
      let chartDom = document.getElementById("main");
      let myChart = echarts.init(chartDom);
      let option;
     
      option = {
        xAxis: {
          type: "category",
          // data: ["消费行业", "生命健康", "传媒娱乐"],
          data: props.typeArr,
        },
        yAxis: {
          type: "value",
        },
        series: [
          {
            // data: [1, 3, 4],
            data: props.echartData,
            type: "bar",
          },
        ],
      };

      option && myChart.setOption(option);
    };

    onMounted(() => {
      console.log("onmoune_props", props);
      init();
    });
    return {
      props,
    };
  },
});
</script>

<style lang='less' scoped>
#main {
  width: 100%;
  height: 100%;
}
</style>